// --------------------------------------------------------------------------------------------------------------------
// <copyright file="UcServer.cs" company="SmartPlan">
//   SmartPlan 2011
// </copyright>
// <summary>
//   Defines the UcServer type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace DbDiff.WinClient.Forms.DbItems
{
    using Common.Helper;
    using Common.Model;

    /// <summary>
    /// The uc server.
    /// </summary>
    public class UcServer : UcDbItem
    {
        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="UcServer"/> class.
        /// </summary>
        /// <param name="data">
        /// The data.
        /// </param>
        public UcServer(DatabaseInfo data)
        {
            this.InitializeComponent();
            this.Data = data;

            this.Init();
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UcServer"/> class.
        /// </summary>
        public UcServer()
        {
            this.InitializeComponent();

            this.Init();
        }

        /// <summary>
        /// The init.
        /// </summary>
        private void Init()
        {
            this.HeaderVisible = true;

            this.DetailsControl = new UcItemProperties(string.Empty);
            this.Toolbar = null;
            this.CommandMenu = null;

            this.Title = "Server properties";
        }

        #endregion Constructors

        #region Designer generated code

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">
        /// The disposing.
        /// </param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
            }

            base.Dispose(disposing);
        }

        /// <summary>
        /// Required method for Designer support - do not modify
        ///   the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.PanelHeader.SuspendLayout();
            this.SuspendLayout();

// PanelDetails
            this.PanelDetails.Name = "panelDetails";

// panelHeader
            this.PanelHeader.Name = "panelHeader";

// LblHeader
            this.LblHeader.Name = "lblHeader";
            this.LblHeader.Text = string.Empty;

// UcServer
            this.Name = "UcServer";
            this.PanelHeader.ResumeLayout(false);
            this.ResumeLayout(false);
        }

        #endregion

        #region Form view / data update

// 		protected override void UpdateView() 

// 		{

// 			base.UpdateView();

// 		}
        /// <summary>
        /// The update form data.
        /// </summary>
        protected override void UpdateFormData()
        {
            this.LblHeader.Text = this.Title;
            ((UcItemProperties)this.DetailsControl).SetData(((DatabaseInfo) this.Data).GetRawDatatable(DatabaseObjectTypes.Server).Rows[0]);
        }

        #endregion Form view / data update

        #region SetData

        /// <summary>
        /// The set data.
        /// </summary>
        /// <param name="names">
        /// The names.
        /// </param>
        /// <param name="values">
        /// The values.
        /// </param>
        public void SetData(string[] names, string[] values)
        {
            if (this.DetailsControl != null)
            {
                ((UcItemProperties)this.DetailsControl).SetData(names, values);
            }
        }

        #endregion SetData
    }
}